#include "ReadyQueue.h"

int readyQueueInit(ReadyQueue * ry){
    ry->front = NULL;
    ry->rear = NULL;
    ry->size = 0;
    return 0;
}

void addQueueNode(ReadyQueue * ry,prams_t * pram){
    QueueNode * p = (QueueNode *)calloc(1,sizeof(QueueNode));
    p->pram = pram;
    if(ry->size == 0){
        ry->front = p;
        ry->rear = p;
    }else{
        ry->rear->next = p;
        ry->rear = p;
    }
    ++ry->size;
}

prams_t * deleteQueueNode(ReadyQueue * ry){
    if(ry->size == 0){
        return NULL;
    }
    QueueNode * p = ry->front;
    prams_t * ret_num = p->pram;
    if(ry->size == 1){
        ry->front = NULL;
        ry->rear = NULL;
        ry->size = 0;
    }else{
        ry->front = p->next;
        --ry->size;
    }
    free(p);
    return ret_num;
}

